﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        public void button1_Click(object sender, EventArgs e)
        {
            string a = "";
            if (this.textBox1.Text == null || this.textBox2.Text == null || int.Parse(this.textBox1.Text) > int.Parse(this.textBox2.Text))
                MessageBox.Show("输入错误");
            else
            {
                int mim = int.Parse(this.textBox1.Text);
                int max = int.Parse(this.textBox2.Text);
                for (int i = mim; i < max; i++)
                {
                    if (i == 2)
                    {
                        a += i;
                        a += ",";
                    }
                    for(int j = 2; j < i; j++)
                    {
                        if (i % j == 0)
                        {
                            break;
                        }
                        if (i - j == 1)
                        {
                            a += i;
                            a += ",";
                        }
                    }
                } 
            }
            if(a=="")
            { MessageBox.Show("上下限之间没有质数"); }
            else 
            { MessageBox.Show("质数有"+a); }
        }

        public void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
